n = int(input())
a = []
for i in range(n):
    a.append(input().split())
a1 = a[:int(n / 2)]
a = a[::-1]
a2 = a[:int(n / 2)]
data = {}
for i in a1:
    for j in a2:
        if i[0] != j[0]:
            data[i[1]] = j[1]
            a2.remove(j)
            break
for k, v in data.items():
    print(k, v)